//
//  AirconditionController.m
//  GBKHOME
//
//  Created by XMYY-19 on 2017/9/5.
//
#import "AirconditionController.h"
#import "Global1.h"
#import "eventAction.h"
#import "LZCircularSlider.h"
#import "eventAction.h"

@interface AirconditionController ()<LZCircularSliderDelegate>
- (IBAction)UDBtn:(UIButton *)sender;
- (IBAction)LRBtn:(UIButton *)sender;
- (IBAction)middleSpeedBtn:(UIButton *)sender;
- (IBAction)highSpeedBtn:(UIButton *)sender;
- (IBAction)lowSpeedBtn:(UIButton *)sender;
- (IBAction)autoSpeedBtn:(UIButton *)sender;
@property (retain, nonatomic) IBOutlet UIButton *switchBtn;
- (IBAction)switchBtn:(UIButton *)sender;
@property (retain, nonatomic) IBOutlet UILabel *moshiState;
@property (retain, nonatomic) IBOutlet UILabel *wenduLabel;
@property (retain, nonatomic) IBOutlet UIButton *topanddownBtn;
@property (retain, nonatomic) IBOutlet UIButton *leftandrightBtn;
@property (retain, nonatomic) IBOutlet UILabel *baifengLabel;
@property (retain, nonatomic) IBOutlet UIButton *highBtn;
@property (retain, nonatomic) IBOutlet UIButton *middleBtn;
@property (retain, nonatomic) IBOutlet UIButton *lowBtn;
@property (retain, nonatomic) IBOutlet UIButton *zidonbgBtn;
@property (retain, nonatomic) IBOutlet UILabel *fengsuLabel;
@property (retain, nonatomic) IBOutlet UILabel *choushiLabel;
@property (retain, nonatomic) IBOutlet UIButton *choushiBtn;
@property (retain, nonatomic) IBOutlet UILabel *choufengLabel;
@property (retain, nonatomic) IBOutlet UIButton *choufengBtn;
@property (retain, nonatomic) IBOutlet UIButton *zhireBtn;
@property (retain, nonatomic) IBOutlet UILabel *zhilengLabel;
@property (retain, nonatomic) IBOutlet UIButton *zhilengBtn;
@property (retain, nonatomic) IBOutlet UILabel *zidongLabel;
@property (retain, nonatomic) IBOutlet UIButton *zidongBtn;
@property (retain, nonatomic) IBOutlet UILabel *moshiLabel;
@property (retain, nonatomic) IBOutlet UISwitch *mySsitch;
@property (retain, nonatomic) IBOutlet UIImageView *myKongtiaoImage;
@property (retain, nonatomic) IBOutlet UILabel *zhireLabel;
@property (retain, nonatomic) IBOutlet UIButton *twentyFourBtn;
@property (retain, nonatomic) IBOutlet UIButton *twentySixBtn;
@property (retain, nonatomic) IBOutlet UIButton *twentyEightBtn;
@property (retain, nonatomic) IBOutlet UIButton *thiryBtn;


@property(nonatomic,assign) BOOL isChangeIndex;


@property(nonatomic,assign)BOOL isClosed;
@property(nonatomic,strong) LZCircularSlider *slider;
@property(nonatomic,assign) CGRect frame;
@property(nonatomic,assign) int oldTemperature;//温度


@end

@implementation AirconditionController

-(id)initWithEquipment:(NewEquipment *)equ
{
    self = [super init];
    if (self)
    {
        self.isClosed = ([equ.state isEqualToString:@"1"]?YES:NO);
        self.equipment = equ;
    }
    return self;
}

- (void)viewDidLoad {
    
    __block CGFloat textFieldLeft;
    __block CGFloat textFieldWidth;
    __block CGFloat logoTop;
    if (IS_IPAD) {
        logoTop = 64+60;
        textFieldWidth = SCREEN_WIDTH/2;
        textFieldLeft = (SCREEN_WIDTH-textFieldWidth)/2;
    } else {
        logoTop = 64+30;
        textFieldWidth = (SCREEN_WIDTH-60)/2;
        textFieldLeft = 30;
    }
    [super viewDidLoad];
    _frame =CGRectMake((SCREEN_WIDTH-270)/2,logoTop-30, 270, 270);
    [self setNavigationTitleView:_equipment.name];
    if (_isClosed) {
        [self.switchBtn setBackgroundImage:[UIImage imageNamed:@"btn_power_on"] forState:UIControlStateNormal];
    }else{
        [self.switchBtn setBackgroundImage:[UIImage imageNamed:@"btn_power_off"] forState:UIControlStateNormal];
    }
    UIImage *image =[UIImage imageNamed:@"mainbg"];
    self.view.layer.contents = (id)image.CGImage;
    
    [self.zidonbgBtn addTarget:self action:@selector(zidongClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.myKongtiaoImage setFrame:(CGRect){(SCREEN_WIDTH-200)/2,logoTop,200,200}];
    [self.wenduLabel setFrame:(CGRect){(SCREEN_WIDTH-160)/2,logoTop+70,160,50}];
    self.wenduLabel.textAlignment = NSTextAlignmentCenter;
    [self.moshiState setFrame:(CGRect){(SCREEN_WIDTH-100)/2,_wenduLabel.bottom+5,100,30}];
    self.moshiState.textAlignment = NSTextAlignmentCenter;
    [self.switchBtn setFrame:(CGRect){(SCREEN_WIDTH-80)/2,_myKongtiaoImage.bottom+10,80,40}];
    
    if (IS_IPAD) {
        [self setIPadFrame];
    } else {
        [self setPhoneFrame];
    }
    [self initSlider];
}

- (void)setIPadFrame{
    CGFloat switchBottomY = _switchBtn.bottom;
    CGFloat ipadLeft = 185;
    CGFloat labelWidth = 40;
    CGFloat smallBtnWidth = 54;
    CGFloat bigBtnWidth = 84;
    
    [self.moshiLabel setFrame:(CGRect){15+ipadLeft,switchBottomY+40,labelWidth,30}];
    [self.choufengBtn setFrame:(CGRect){70+ipadLeft,switchBottomY+20,smallBtnWidth,smallBtnWidth}];
    [self.choushiBtn setFrame:(CGRect){120+ipadLeft,switchBottomY+20,smallBtnWidth,smallBtnWidth}];
    [self.choufengLabel setFrame:(CGRect){75+ipadLeft,switchBottomY+74,labelWidth,30}];
    [self.choushiLabel setFrame:(CGRect){125+ipadLeft,switchBottomY+74,labelWidth,30}];
    
    CGFloat moshiBottomY = _moshiLabel.bottom;
    CGFloat lineMargin = 40;
    [self.fengsuLabel setFrame:(CGRect){15+ipadLeft,moshiBottomY+lineMargin,labelWidth,30}];
    [self.zidonbgBtn setFrame:(CGRect){70+ipadLeft,moshiBottomY+lineMargin,bigBtnWidth,30}];
    [self.lowBtn setFrame:(CGRect){165+ipadLeft,moshiBottomY+lineMargin,bigBtnWidth,30}];
    [self.middleBtn setFrame:(CGRect){260+ipadLeft,moshiBottomY+lineMargin,bigBtnWidth,30}];
    [self.highBtn setFrame:(CGRect){352+ipadLeft,moshiBottomY+lineMargin,bigBtnWidth,30}];
    
    CGFloat fengsuBottomY = _fengsuLabel.bottom;
    [self.baifengLabel setFrame:(CGRect){15+ipadLeft,fengsuBottomY+lineMargin,labelWidth,30}];
    [self.leftandrightBtn setFrame:(CGRect){70+ipadLeft,fengsuBottomY+lineMargin,bigBtnWidth,30}];
    [self.topanddownBtn setFrame:(CGRect){165+ipadLeft,fengsuBottomY+lineMargin,bigBtnWidth,30}];
}

- (void)setPhoneFrame{

    CGFloat zhireBottomY = _switchBtn.bottom+10;
    [self.zhireLabel setFrame:(CGRect){15,zhireBottomY,60,30}];
    [self.twentyFourBtn setFrame:(CGRect){60,zhireBottomY,60,30}];
    [self.twentySixBtn setFrame:(CGRect){125,zhireBottomY,60,30}];
    [self.twentyEightBtn setFrame:(CGRect){190,zhireBottomY,60,30}];
    [self.thiryBtn setFrame:(CGRect){255,zhireBottomY,60,30}];
    
    CGFloat switchBottomY = _switchBtn.bottom+30;
    [self.moshiLabel setFrame:(CGRect){10,switchBottomY+40,40,30}];
    [self.choufengBtn setFrame:(CGRect){70,switchBottomY+20,40,40}];
    [self.choushiBtn setFrame:(CGRect){120,switchBottomY+20,40,40}];
    [self.choufengLabel setFrame:(CGRect){70,switchBottomY+60,40,30}];
    [self.choushiLabel setFrame:(CGRect){120,switchBottomY+60,40,30}];
    
    CGFloat moshiBottomY = _moshiLabel.bottom+25;
    [self.fengsuLabel setFrame:(CGRect){15,moshiBottomY,40,30}];
    [self.zidonbgBtn setFrame:(CGRect){60,moshiBottomY,60,30}];
    [self.lowBtn setFrame:(CGRect){125,moshiBottomY,60,30}];
    [self.middleBtn setFrame:(CGRect){190,moshiBottomY,60,30}];
    [self.highBtn setFrame:(CGRect){255,moshiBottomY,60,30}];
    
    CGFloat fengsuBottomY = _fengsuLabel.bottom+15;
    [self.baifengLabel setFrame:(CGRect){15,fengsuBottomY,40,30}];
    [self.leftandrightBtn setFrame:(CGRect){60,fengsuBottomY,60,30}];
    [self.topanddownBtn setFrame:(CGRect){125,fengsuBottomY,60,30}];

}

-(void)initSlider{
    _slider =[[LZCircularSlider alloc]initWithFrame:_frame];
    /*
     following number must set,or have issue
     */
    _slider.lineWidth =8;
    _slider.maximumValue =30;
    _slider.minimumValue =16;
    _slider.currentValue =1.0;
    _slider.downCurrentValue =1.0;
    _slider.downMaximumValue =30;
    _slider.downMinimumValue =24;
    _slider.delegate = self;
    _slider.unfilledColor =[UIColor colorWithRed:192/255.0 green:192/255.0 blue:192/255.0 alpha:1];
    _slider.filledColor =[UIColor colorWithRed:255/255.0 green:127/255.0 blue:80/255.0 alpha:1];
    _slider.downFilledColor =[UIColor colorWithRed:65/255.0 green:105/255.0 blue:225/255.0 alpha:1];
    _slider.backgroundColor =[UIColor clearColor];
//    [_slider addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged];
    [self.view addSubview:_slider];

}

-(void)zidongClick:(UIButton *)sender
{
}

- (void)viewWillAppear:(BOOL)animated{
    self.tabBarController.tabBar.hidden = YES;
}

- (void)viewWillDisappear:(BOOL)animated{
    self.tabBarController.tabBar.hidden = NO;
}

-(void)setMoshiLabel:(UILabel *)moshiLabel
{
    _moshiLabel = moshiLabel;
    moshiLabel.textAlignment = NSTextAlignmentCenter;
    moshiLabel.font =[UIFont systemFontOfSize:15];
    
    moshiLabel.textColor = [UIColor colorWithRGBColorByString:@"#f8f9fa"];
}

-(void)setZidonbgBtn:(UIButton *)zidonbgBtn
{
    _zidonbgBtn =zidonbgBtn;
    [zidonbgBtn setBackgroundColor:[UIColor colorWithRGBColorByString:@"#17174c"]];
    [zidonbgBtn.layer setCornerRadius:15];
}

-(void)setLowBtn:(UIButton *)lowBtn
{
    _lowBtn = lowBtn;
    [lowBtn setBackgroundColor:[UIColor colorWithRGBColorByString:@"#17174c"]];
    [lowBtn.layer setCornerRadius:15];
}

-(void)setMiddleBtn:(UIButton *)middleBtn
{
    _middleBtn = middleBtn;
    [middleBtn setBackgroundColor:[UIColor colorWithRGBColorByString:@"#17174c"]];
    [middleBtn.layer setCornerRadius:15];
}

-(void)setHighBtn:(UIButton *)highBtn
{
    _highBtn = highBtn;
    [highBtn setBackgroundColor:[UIColor colorWithRGBColorByString:@"#17174c"]];
    [highBtn.layer setCornerRadius:15];
}

-(void)setLeftandrightBtn:(UIButton *)leftandrightBtn
{
    _leftandrightBtn = leftandrightBtn;
    [leftandrightBtn setBackgroundColor:[UIColor colorWithRGBColorByString:@"#17174c"]];
    [leftandrightBtn.layer setCornerRadius:15];
}

-(void)setTopanddownBtn:(UIButton *)topanddownBtn
{
    _topanddownBtn = topanddownBtn;
    [topanddownBtn setBackgroundColor:[UIColor colorWithRGBColorByString:@"#17174c"]];
    [topanddownBtn.layer setCornerRadius:15];
}

-(void)setTwentyFourBtn:(UIButton *)twentyFourBtn
{
    _twentyFourBtn =twentyFourBtn;
    [twentyFourBtn setBackgroundColor:[UIColor colorWithRGBColorByString:@"#17174c"]];
    [twentyFourBtn.layer setCornerRadius:15];
}

-(void)setTwentySixBtn:(UIButton *)twentySixBtn
{
    _twentySixBtn =twentySixBtn;
    [twentySixBtn setBackgroundColor:[UIColor colorWithRGBColorByString:@"#17174c"]];
    [twentySixBtn.layer setCornerRadius:15];
}

-(void)setTwentyEightBtn:(UIButton *)twentyEightBtn
{
    _twentyEightBtn =twentyEightBtn;
    [twentyEightBtn setBackgroundColor:[UIColor colorWithRGBColorByString:@"#17174c"]];
    [twentyEightBtn.layer setCornerRadius:15];
}

-(void)setThiryBtn:(UIButton *)thiryBtn
{
    _thiryBtn =thiryBtn;
    [thiryBtn setBackgroundColor:[UIColor colorWithRGBColorByString:@"#17174c"]];
    [thiryBtn.layer setCornerRadius:15];
}

- (void)dealloc {
    [_myKongtiaoImage release];
    [_mySsitch release];
    [_moshiLabel release];
    [_zidongBtn release];
    [_zidongLabel release];
    [_zhilengBtn release];
    [_zhilengLabel release];
    [_zhireBtn release];
    [_zhireLabel release];
    [_choufengBtn release];
    [_choufengLabel release];
    [_choushiBtn release];
    [_choushiLabel release];
    [_fengsuLabel release];
    [_zidonbgBtn release];
    [_lowBtn release];
    [_middleBtn release];
    [_highBtn release];
    [_baifengLabel release];
    [_leftandrightBtn release];
    [_topanddownBtn release];
    [_wenduLabel release];
    [_moshiState release];
    [_switchBtn release];
    [_zhireLabel release];
    [super dealloc];
}

#pragma mark--空调开关
- (IBAction)switchBtn:(UIButton *)sender {
    
    BOOL isOpen = NO;
    NSString *switchId = self.equipment.switchId;
    if(self.isClosed)
    {
        self.isClosed = NO;
        isOpen = NO;
    }
    else
    {
        self.isClosed = YES;
        isOpen = YES;
    }
    [eventAction electricCompantWithOrder:isOpen swtichId:switchId result:^(NSDictionary *dic) {
        [self ctlDeviceEnd:dic];
        if(isOpen && [[dic objectForKey:@"result"] isEqualToString:@"0"])
        {
            
            [self.switchBtn setBackgroundImage:[UIImage imageNamed:@"btn_power_on"] forState:UIControlStateNormal];
            
        }
        else
        {
            [self.switchBtn setBackgroundImage:[UIImage imageNamed:@"btn_power_off"] forState:UIControlStateNormal];
            //72 34
        }
    }];
}

- (void)ctlDeviceEnd:(NSDictionary *)dic
{
    if (self.equipment == nil) {//后台刷新电器状态，更新状态，已重载电器，此电器已释放
        NSLog(@"nil");
        return;
    }
    NSString *tip = @"";
    BOOL OPEN = [DeviceView deviceStateOn:self.equipment];
    BOOL STATE = !OPEN;
    NSNumber *result = [dic objectForKey:@"result"];
    if (result.integerValue == 0) {
        
        tip = [OperationTip operat:self.equipment.name open:STATE result:YES errorType:ErrorTypeServerReturnFail];
        [self setDeviceOn:STATE];
        
        GKBMainController *main = [GKBMainController mainCtr];
        [main updateStateByNet];
    }
    else
    {
        tip = [OperationTip operat:self.equipment.name open:STATE result:NO errorType:ErrorTypeServerReturnFail];
    }
    
    [iToast showTip:tip gravity:iToastGravityBottom];
}

- (void)setDeviceOn:(BOOL)on
{
    //    self.Switch = on;
    //    self.button.selected = on;
    if (on) {
        //        [self.button setBackgroundImage:[UIImage imageNamed:@"green.png"] forState:UIControlStateNormal];
        self.equipment.state = kStateON;
    }
    else
    {
        //        [self.button setBackgroundImage:[UIImage imageNamed:@"lightBlue.png"] forState:UIControlStateNormal];
        self.equipment.state = kStateOFF;
    }
    
    
    // [self updateProtectName];
    
}

#pragma mark--上下风向
- (IBAction)UDBtn:(UIButton *)sender
{
    NSString *order = @"DOWNWIND";
    NSString *switchId = self.equipment.switchId;
    
    NSString *sessionId = [LoginController1 sessionID];
    NSString *fomat = @"[{\"orderId\":\"%@\", \"switchId\":\"%@\", \"sessionId\":\"%@\"}]";
    NSString *body = [NSString stringWithFormat:fomat, order, switchId, sessionId];
    [WebServices setShowConnectting:NO];
    [WebServices requestSynStartOrder:@"ctlAC" body:body result:^(NSDictionary *dic) {
        [self ctlDeviceInfo:dic tipName:@"风向下"];
    }];
}

#pragma mark--左右
- (IBAction)LRBtn:(UIButton *)sender
{
    NSString *order = @"UPWIND";
    NSString *switchId = self.equipment.switchId;
    
    NSString *sessionId = [LoginController1 sessionID];
    NSString *fomat = @"[{\"orderId\":\"%@\", \"switchId\":\"%@\", \"sessionId\":\"%@\"}]";
    NSString *body = [NSString stringWithFormat:fomat, order, switchId, sessionId];
    [WebServices setShowConnectting:NO];
    [WebServices requestSynStartOrder:@"ctlAC" body:body result:^(NSDictionary *dic) {
        [self ctlDeviceInfo:dic tipName:@"风向上"];
    }];
}

- (IBAction)middleSpeedBtn:(UIButton *)sender {
    NSString *order = @"MID";
    NSString *switchId = self.equipment.switchId;
    
    NSString *sessionId = [LoginController1 sessionID];
    NSString *fomat = @"[{\"orderId\":\"%@\", \"switchId\":\"%@\", \"sessionId\":\"%@\"}]";
    NSString *body = [NSString stringWithFormat:fomat, order, switchId, sessionId];
    [WebServices setShowConnectting:NO];
    [WebServices requestSynStartOrder:@"ctlAC" body:body result:^(NSDictionary *dic) {
        [self ctlDeviceInfo:dic tipName:@"中级风速"];
    }];
}

#pragma mark--高级速度
- (IBAction)highSpeedBtn:(UIButton *)sender {
    NSString *order = @"HIGH";
    NSString *switchId = self.equipment.switchId;
    
    NSString *sessionId = [LoginController1 sessionID];
    NSString *fomat = @"[{\"orderId\":\"%@\", \"switchId\":\"%@\", \"sessionId\":\"%@\"}]";
    NSString *body = [NSString stringWithFormat:fomat, order, switchId, sessionId];
    [WebServices setShowConnectting:NO];
    [WebServices requestSynStartOrder:@"ctlAC" body:body result:^(NSDictionary *dic) {
        [self ctlDeviceInfo:dic tipName:@"高级风速"];
    }];
}

#pragma mark--低级速度
- (IBAction)lowSpeedBtn:(UIButton *)sender
{
    NSString *order = @"LOW";
    NSString *switchId = self.equipment.switchId;
    
    NSString *sessionId = [LoginController1 sessionID];
    NSString *fomat = @"[{\"orderId\":\"%@\", \"switchId\":\"%@\", \"sessionId\":\"%@\"}]";
    NSString *body = [NSString stringWithFormat:fomat, order, switchId, sessionId];
    [WebServices setShowConnectting:NO];
    [WebServices requestSynStartOrder:@"ctlAC" body:body result:^(NSDictionary *dic) {
        [self ctlDeviceInfo:dic tipName:@"低级风速"];
    }];
}

#pragma mark--风速自动
- (IBAction)autoSpeedBtn:(UIButton *)sender {
    NSString *order = @"AUTO";
    NSString *switchId = self.equipment.switchId;
    
    NSString *sessionId = [LoginController1 sessionID];
    NSString *fomat = @"[{\"orderId\":\"%@\", \"switchId\":\"%@\", \"sessionId\":\"%@\"}]";
    NSString *body = [NSString stringWithFormat:fomat, order, switchId, sessionId];
    [WebServices setShowConnectting:NO];
    [WebServices requestSynStartOrder:@"ctlAC" body:body result:^(NSDictionary *dic) {
        [self ctlDeviceInfo:dic tipName:@"自动风速"];
    }];
}

- (IBAction)warnTwenthyFourBtn:(id)sender {
    [self airconditionWarning:0];
}

- (IBAction)warnTwenthySixBtn:(id)sender {
    [self airconditionWarning:2];
}

- (IBAction)warnTwenthyEightBtn:(id)sender {
    [self airconditionWarning:4];
}

- (IBAction)warnThirtyBtn:(id)sender {
    [self airconditionWarning:6];
}

-(void)ctlDeviceInfo:(NSDictionary *)dict tipName:(NSString *)tipName
{
    if (self.equipment == nil) {//后台刷新电器状态，更新状态，已重载电器，此电器已释放
        NSLog(@"nil");
        return;
    }
    NSString *tip = @"";
    BOOL OPEN = [DeviceView deviceStateOn:self.equipment];
    BOOL STATE = !OPEN;
    NSNumber *result = [dict objectForKey:@"result"];
    if (result.integerValue == 0) {
        
        tip = [OperationTip operat:tipName open:STATE result:YES errorType:ErrorTypeServerReturnFail];
        [self setDeviceOn:STATE];
        
        GKBMainController *main = [GKBMainController mainCtr];
        [main updateStateByNet];
    }
    else
    {
        tip = [OperationTip operat:self.equipment.name open:STATE result:NO errorType:ErrorTypeServerReturnFail];
    }
    
    [iToast showTip:tip gravity:iToastGravityBottom];
}

#pragma mark --slider滑动条delegate function
-(void)upHandle:(int)curValue{
    int curTemperature = curValue+16;
        if (curTemperature != _oldTemperature && curTemperature%2 == 0) {
        NSString * temperString;
        temperString = [NSString stringWithFormat:@"%d",curTemperature];
        _wenduLabel.text =[NSString stringWithFormat:@"%@",temperString];
        _moshiState.text = @"制冷";
        NSString *order = [[NSString alloc]initWithFormat:@"%d",curTemperature];
        [eventAction airconditionCtrlWithOrder:order switchId:self.equipment.switchId result:^(NSDictionary *dic) {
            NSString *tips = [[NSString alloc]initWithFormat:@"操作成功：制冷 %@℃",temperString];
            [self airconfitionTip:dic tipName:tips];
        }];
    }
}

-(void)downHandle:(int)curValue{
    [self airconditionWarning:curValue];
}

- (void)airconditionWarning:(int)curValue{
    int curTemperature = curValue+24;
    if (curTemperature != _oldTemperature && curTemperature%2 == 0) {
        NSString * temperString;
        temperString = [NSString stringWithFormat:@"%d",curTemperature];
        _wenduLabel.text = temperString;
        _moshiState.text = @"制热";
        NSString *order = [[NSString alloc]initWithFormat:@"H%d",curTemperature];
        [eventAction airconditionCtrlWithOrder:order switchId:self.equipment.switchId result:^(NSDictionary *dic) {
            NSString *tips = [[NSString alloc]initWithFormat:@"操作成功：制热 %@℃",temperString];
            [self airconfitionTip:dic tipName:tips];
        }];
    }
}

-(void)airconfitionTip:(NSDictionary *)dict tipName:(NSString *)tipName
{
    NSString *tip = @"";
    BOOL OPEN = [DeviceView deviceStateOn:self.equipment];
    BOOL STATE = !OPEN;
    NSNumber *result = [dict objectForKey:@"result"];
    if (result.integerValue == 0) {
        
        tip = tipName;
        [self setDeviceOn:STATE];
        
        GKBMainController *main = [GKBMainController mainCtr];
        [main updateStateByNet];
    }
    else
    {
        tip = [OperationTip operat:self.equipment.name open:STATE result:NO errorType:ErrorTypeServerReturnFail];
    }
    
    [iToast showTip:tip gravity:iToastGravityBottom];
}

-(void)valueChanged:(LZCircularSlider*)slider {
    //    NSString * topString;
    //    NSString * downString;
    //    NSString * centerString;
    //    topString = [NSString stringWithFormat:@"%d",slider.currentValue+16];
    //    downString =[NSString stringWithFormat:@"%d",slider.downCurrentValue];
    //    _wenduLabel.text =[NSString stringWithFormat:@"%@",topString];
    //    NSLog(@"upCurrentValue==%d=====",slider.currentValue);
    ////    NSLog(@"downCurrentValue====%d",slider.downCurrentValue);
    
}

@end
